let List_Type = {};

//% color="#EEAA00" iconWidth=30 iconHeight=30
namespace iWall {
    //% block="microbit重置" blockType="command" board="microbit"
    export function microbit_reset(parameter: any, block: any) {
        Generator.addCode(`NVIC_SystemReset();`)
    }

    //% block="创建数组[LIST_NAME]类型[LIST_TYPE]" blockType="command"
    //% LIST_NAME.shadow="string" LIST_NAME.defl="myList"
    //% LIST_TYPE.shadow="dropdown" LIST_TYPE.options="LIST_TYPE"
    export function list_create(parameter: any, block: any) {
        let list_name = parameter.LIST_NAME.code;
        let list_type = parameter.LIST_TYPE.code;
        List_Type[list_name] = list_type;
        Generator.addInclude(`List`, `#include "List.h"`);
        Generator.addObject(`${list_name.slice(1, -1)}`, `List<${list_type}>`, `${list_name.slice(1, -1)};`);
    }

    //% block="在数组[LIST_NAME]开头插入[VALUE]" blockType="command"
    //% LIST_NAME.shadow="string" LIST_NAME.defl="myList"
    //% VALUE.shadow="string" VALUE.defl="0"
    export function list_unshift(parameter: any, block: any) {
        let list_name = parameter.LIST_NAME.code;
        let value = parameter.VALUE.code;
        if (List_Type[list_name] == "String")
            Generator.addCode(`${list_name.slice(1, -1)}.push_front(${value});`);
        else if (value[0] == '"' && value[value.length - 1] == '"')
            Generator.addCode(`${list_name.slice(1, -1)}.push_front(${value.slice(1, -1)});`);
        else
            Generator.addCode(`${list_name.slice(1, -1)}.push_front(${value});`);
    }

    //% block="在数组[LIST_NAME]结尾插入[VALUE]" blockType="command"
    //% LIST_NAME.shadow="string" LIST_NAME.defl="myList"
    //% VALUE.shadow="string" VALUE.defl="0"
    export function list_push(parameter: any, block: any) {
        let list_name = parameter.LIST_NAME.code;
        let value = parameter.VALUE.code;
        if (List_Type[list_name] == "String")
            Generator.addCode(`${list_name.slice(1, -1)}.push_back(${value});`);
        else if (value[0] == '"' && value[value.length - 1] == '"')
            Generator.addCode(`${list_name.slice(1, -1)}.push_back(${value.slice(1, -1)});`);
        else
            Generator.addCode(`${list_name.slice(1, -1)}.push_back(${value});`);
    }

    //% block="在数组[LIST_NAME]索引[INDEX]处插入[VALUE]" blockType="command"
    //% LIST_NAME.shadow="string" LIST_NAME.defl="myList"
    //% INDEX.shadow="number" INDEX.defl="0"
    //% VALUE.shadow="string" VALUE.defl="0"
    export function list_insertAt(parameter: any, block: any) {
        let list_name = parameter.LIST_NAME.code;
        let index = parameter.INDEX.code;
        let value = parameter.VALUE.code;
        if (List_Type[list_name] == "String")
            Generator.addCode(`${list_name.slice(1, -1)}.insert(${index},${value});`);
        else if (value[0] == '"' && value[value.length - 1] == '"')
            Generator.addCode(`${list_name.slice(1, -1)}.insert(${index},${value.slice(1, -1)});`);
        else
            Generator.addCode(`${list_name.slice(1, -1)}.insert(${index},${value});`);
    }

    //% block="从数组[LIST_NAME]中移除第一个元素" blockType="command"
    //% LIST_NAME.shadow="string" LIST_NAME.defl="myList"
    export function list_removeFirst(parameter: any, block: any) {
        let list_name = parameter.LIST_NAME.code;
        Generator.addCode(`${list_name.slice(1, -1)}.pop_front();`);
    }

    //% block="从数组[LIST_NAME]中移除最后一个元素" blockType="command"
    //% LIST_NAME.shadow="string" LIST_NAME.defl="myList"
    export function list_removeLast(parameter: any, block: any) {
        let list_name = parameter.LIST_NAME.code;
        Generator.addCode(`${list_name.slice(1, -1)}.pop_back();`);
    }

    //% block="从数组[LIST_NAME]中移除索引[INDEX]处的元素" blockType="command"
    //% LIST_NAME.shadow="string" LIST_NAME.defl="myList"
    //% INDEX.shadow="number" INDEX.defl="0"
    export function list_removeAt(parameter: any, block: any) {
        let list_name = parameter.LIST_NAME.code;
        let index = parameter.INDEX.code;
        Generator.addCode(`${list_name.slice(1, -1)}.remove(${index});`);
    }

    //% block="从数组[LIST_NAME]中移除所有元素" blockType="command"
    //% LIST_NAME.shadow="string" LIST_NAME.defl="myList"
    export function list_destroy(parameter: any, block: any) {
        let list_name = parameter.LIST_NAME.code;
        Generator.addCode(`${list_name.slice(1, -1)}.clear();`);
    }

    //% block="将数组[LIST_NAME]中第一个元素修改为[VALUE]" blockType="command"
    //% LIST_NAME.shadow="string" LIST_NAME.defl="myList"
    //% VALUE.shadow="string" VALUE.defl="0"
    export function list_replaceFirst(parameter: any, block: any) {
        let list_name = parameter.LIST_NAME.code;
        let value = parameter.VALUE.code;
        if (List_Type[list_name] == "String")
            Generator.addCode(`${list_name.slice(1, -1)}.replace(0,${value});`);
        else if (value[0] == '"' && value[value.length - 1] == '"')
            Generator.addCode(`${list_name.slice(1, -1)}.replace(0,${value.slice(1, -1)});`);
        else
            Generator.addCode(`${list_name.slice(1, -1)}.replace(0,${value});`);
    }

    //% block="将数组[LIST_NAME]中最后一个元素修改为[VALUE]" blockType="command"
    //% LIST_NAME.shadow="string" LIST_NAME.defl="myList"
    //% VALUE.shadow="string" VALUE.defl="0"
    export function list_replaceLast(parameter: any, block: any) {
        let list_name = parameter.LIST_NAME.code;
        let value = parameter.VALUE.code;
        if (List_Type[list_name] == "String")
            Generator.addCode(`${list_name.slice(1, -1)}.replace(${list_name.slice(1, -1)}.size()-1,${value});`);
        else if (value[0] == '"' && value[value.length - 1] == '"')
            Generator.addCode(`${list_name.slice(1, -1)}.replace(${list_name.slice(1, -1)}.size()-1,${value.slice(1, -1)});`);
        else
            Generator.addCode(`${list_name.slice(1, -1)}.replace(${list_name.slice(1, -1)}.size()-1,${value});`);
    }

    //% block="将数组[LIST_NAME]中索引[INDEX]处的元素修改为[VALUE]" blockType="command"
    //% LIST_NAME.shadow="string" LIST_NAME.defl="myList"
    //% INDEX.shadow="number" INDEX.defl="0"
    //% VALUE.shadow="string" VALUE.defl="0"
    export function list_replaceAt(parameter: any, block: any) {
        let list_name = parameter.LIST_NAME.code;
        let index = parameter.INDEX.code;
        let value = parameter.VALUE.code;
        if (List_Type[list_name] == "String")
            Generator.addCode(`${list_name.slice(1, -1)}.replace(${index},${value});`);
        else if (value[0] == '"' && value[value.length - 1] == '"')
            Generator.addCode(`${list_name.slice(1, -1)}.replace(${index},${value.slice(1, -1)});`);
        else
            Generator.addCode(`${list_name.slice(1, -1)}.replace(${index},${value});`);
    }

    //% block="翻转数组[LIST_NAME]" blockType="command"
    //% LIST_NAME.shadow="string" LIST_NAME.defl="myList"
    export function list_reserve(parameter: any, block: any) {
        let list_name = parameter.LIST_NAME.code;
        Generator.addCode(`${list_name.slice(1, -1)}.reserve(${list_name.slice(1, -1)}.size());`);
    }

    //% block="数组[LIST_NAME]的长度" blockType="reporter"
    //% LIST_NAME.shadow="string" LIST_NAME.defl="myList"
    export function list_getLength(parameter: any, block: any) {
        let list_name = parameter.LIST_NAME.code;
        Generator.addCode(`${list_name.slice(1, -1)}.size()`);
    }

    //% block="从数组[LIST_NAME]中取得索引[INDEX]的值" blockType="reporter"
    //% LIST_NAME.shadow="string" LIST_NAME.defl="myList"
    //% INDEX.shadow="number" INDEX.defl="0"
    export function list_getIndexValue(parameter: any, block: any) {
        let list_name = parameter.LIST_NAME.code;
        let index = parameter.INDEX.code;
        Generator.addCode(`${list_name.slice(1, -1)}[${index}]`);
    }

    //% block="从数组[LIST_NAME]中取得第一个值" blockType="reporter"
    //% LIST_NAME.shadow="string" LIST_NAME.defl="myList"
    export function list_getFirst(parameter: any, block: any) {
        let list_name = parameter.LIST_NAME.code;
        Generator.addCode(`${list_name.slice(1, -1)}[0]`);
    }

    //% block="从数组[LIST_NAME]中取得最后一个值" blockType="reporter"
    //% LIST_NAME.shadow="string" LIST_NAME.defl="myList"
    export function list_getLast(parameter: any, block: any) {
        let list_name = parameter.LIST_NAME.code;
        Generator.addCode(`${list_name.slice(1, -1)}[${list_name.slice(1, -1)}.size()-1]`);
    }

    //% block="在数组[LIST_NAME]中查找值[VALUE]的索引" blockType="reporter"
    //% LIST_NAME.shadow="string" LIST_NAME.defl="myList"
    //% VALUE.shadow="string" VALUE.defl="0"
    export function list_indexOf(parameter: any, block: any) {
        let list_name = parameter.LIST_NAME.code;
        let value = parameter.VALUE.code;
        if (List_Type[list_name] == "String")
            Generator.addCode(`${list_name.slice(1, -1)}.indexOf(${value})`);
        else if (value[0] == '"' && value[value.length - 1] == '"')
            Generator.addCode(`${list_name.slice(1, -1)}.indexOf(${value.slice(1, -1)})`);
        else
            Generator.addCode(`${list_name.slice(1, -1)}.indexOf(${value})`);
    }

    //% block="在数组[LIST_NAME]中是否包含值[VALUE]" blockType="boolean"
    //% LIST_NAME.shadow="string" LIST_NAME.defl="myList"
    //% VALUE.shadow="string" VALUE.defl="0"
    export function list_indexOf(parameter: any, block: any) {
        let list_name = parameter.LIST_NAME.code;
        let value = parameter.VALUE.code;
        if (List_Type[list_name] == "String")
            Generator.addCode(`${list_name.slice(1, -1)}.contains(${value})`);
        else if (value[0] == '"' && value[value.length - 1] == '"')
            Generator.addCode(`${list_name.slice(1, -1)}.contains(${value.slice(1, -1)})`);
        else
            Generator.addCode(`${list_name.slice(1, -1)}.contains(${value})`);
    }

    //% block="---"
    export function noteSep0() {

    }

    //% block="iWall初始化" blockType="command"
    export function iWall_init_microbit(parameter: any, block: any) {
        Generator.addInclude('IWall', '#include "IWall.h"');
        Generator.addObject(`iWall`, `IWall`, `iWall;`);
        Generator.addSetup(`iWall_Init`, `iWall.iWall_Init();`)
    }

    //% block="新计时器" blockType="reporter"
    export function iWall_createTimer(parameter: any, block: any) {
        Generator.addCode(`iWall.iWall_createTimer()`);
    }

    //% block="获取计时器[TIMER]的时间（毫秒）" blockType="reporter"
    //% TIMER.shadow="string" TIMER.defl="Timer"
    export function iWall_GetTimerValue(parameter: any, block: any) {
        let timer = parameter.TIMER.code;
        Generator.addCode(`iWall.iWall_GetTimerValue(${timer})`);
    }

    //% block="清零计时器[TIMER]" blockType="command"
    //% TIMER.shadow="string" TIMER.defl="Timer"
    export function iWall_ClearTimer(parameter: any, block: any) {
        let timer = parameter.TIMER.code;
        Generator.addCode(`iWall.iWall_ClearTimer(${timer});`);
    }

    //% block="---"
    export function noteSep1() {

    }

    //% block="创建角色 类型[CHARACTER_TYPE] X[POSITION_X] Y[POSITION_Y]" blockType="reporter"
    //% CHARACTER_TYPE.shadow="dropdown" CHARACTER_TYPE.options="CHARACTER_TYPE"
    //% POSITION_X.shadow="number" POSITION_X.defl="0"
    //% POSITION_Y.shadow="number" POSITION_Y.defl="0"
    export function iWall_createCharacter(parameter: any, block: any) {
        let character_type = parameter.CHARACTER_TYPE.code;
        let position_x = parameter.POSITION_X.code;
        let position_y = parameter.POSITION_Y.code;
        Generator.addCode(`iWall.iWall_createCharacter("${character_type}", ${position_x}, ${position_y})`);
    }

    //% block="删除角色[CHARACTER]" blockType="command"
    //% CHARACTER.shadow="string" CHARACTER.defl="Sprite"
    export function iWall_deleteCharacter(parameter: any, block: any) {
        let character = parameter.CHARACTER.code;
        Generator.addCode(`iWall.iWall_deleteCharacter(${character});`);
    }

    //% block="角色[CHARACTER]移动[STEP]" blockType="command"
    //% CHARACTER.shadow="string" CHARACTER.defl="Sprite"
    //% STEP.shadow="number" STEP.defl="1"
    export function iWall_characterMove(parameter: any, block: any) {
        let character = parameter.CHARACTER.code;
        let step = parameter.STEP.code;
        Generator.addCode(`iWall.iWall_characterMove(${character}, ${step});`);
    }

    //% block="角色[CHARACTER]设置类型[CHARACTER_TYPE]" blockType="command"
    //% CHARACTER.shadow="string" CHARACTER.defl="Sprite"
    //% CHARACTER_TYPE.shadow="dropdown" CHARACTER_TYPE.options="CHARACTER_TYPE"
    export function iWall_characterSetGraph(parameter: any, block: any) {
        let character = parameter.CHARACTER.code;
        let character_type = parameter.CHARACTER_TYPE.code;
        Generator.addCode(`iWall.iWall_characterSetGraph(${character}, "${character_type}");`);
    }

    //% block="角色[CHARACTER]设置[GRAPHDIRECT]" blockType="command"
    //% CHARACTER.shadow="string" CHARACTER.defl="Sprite"
    //% GRAPHDIRECT.shadow="dropdown" GRAPHDIRECT.options="GRAPHDIRECT"
    export function iWall_characterSetGraphDirect(parameter: any, block: any) {
        let character = parameter.CHARACTER.code;
        let graphDirect = parameter.GRAPHDIRECT.code;
        Generator.addCode(`iWall.iWall_characterSetGraphDirect(${character}, ${graphDirect});`);
    }

    //% block="角色[CHARACTER]设置[MOTIONDIRECT]" blockType="command"
    //% CHARACTER.shadow="string" CHARACTER.defl="Sprite"
    //% MOTIONDIRECT.shadow="dropdown" MOTIONDIRECT.options="MOTIONDIRECT"
    export function iWall_characterSetMotionDirect(parameter: any, block: any) {
        let character = parameter.CHARACTER.code;
        let motionDirect = parameter.MOTIONDIRECT.code;
        Generator.addCode(`iWall.iWall_characterSetMotionDirect(${character}, ${motionDirect});`);
    }

    //% block="角色[CHARACTER]移动到X[POSITION_X]Y[POSITION_Y]" blockType="command"
    //% CHARACTER.shadow="string" CHARACTER.defl="Sprite"
    //% POSITION_X.shadow="number" POSITION_X.defl="0"
    //% POSITION_Y.shadow="number" POSITION_Y.defl="0"
    export function iWall_characterSetXY(parameter: any, block: any) {
        let character = parameter.CHARACTER.code;
        let position_x = parameter.POSITION_X.code;
        let position_y = parameter.POSITION_Y.code;
        Generator.addCode(`iWall.iWall_characterSetXY(${character}, ${position_x}, ${position_y});`);
    }

    //% block="角色[CHARACTER]设置[AXIS]为[AXIS_NUMBER]" blockType="command"
    //% CHARACTER.shadow="string" CHARACTER.defl="Sprite"
    //% AXIS.shadow="dropdown" AXIS.options="AXIS"
    //% AXIS_NUMBER.shadow="number" AXIS_NUMBER.defl="0"
    export function iWall_characterSetAxis(parameter: any, block: any) {
        let character = parameter.CHARACTER.code;
        let axis = parameter.AXIS.code;
        let axis_number = parameter.AXIS_NUMBER.code;
        Generator.addCode(`iWall.iWall_characterSetAxis(${character}, ${axis}, ${axis_number});`);
    }

    //% block="角色[CHARACTER]X偏移[OFFSET_X]Y偏移[OFFSET_Y]" blockType="command"
    //% CHARACTER.shadow="string" CHARACTER.defl="Sprite"
    //% OFFSET_X.shadow="number" OFFSET_X.defl="0"
    //% OFFSET_Y.shadow="number" OFFSET_Y.defl="0"
    export function iWall_characterSetXYOffset(parameter: any, block: any) {
        let character = parameter.CHARACTER.code;
        let offset_x = parameter.OFFSET_X.code;
        let offset_y = parameter.OFFSET_Y.code;
        Generator.addCode(`iWall.iWall_characterSetXYOffset(${character}, ${offset_x}, ${offset_y});`);
    }

    //% block="角色[CHARACTER][AXIS]偏移[AXIS_NUMBER]" blockType="command"
    //% CHARACTER.shadow="string" CHARACTER.defl="Sprite"
    //% AXIS.shadow="dropdown" AXIS.options="AXIS"
    //% AXIS_NUMBER.shadow="number" AXIS_NUMBER.defl="0"
    export function iWall_characterSetAxisOffset(parameter: any, block: any) {
        let character = parameter.CHARACTER.code;
        let axis = parameter.AXIS.code;
        let axis_number = parameter.AXIS_NUMBER.code;
        Generator.addCode(`iWall.iWall_characterSetAxisOffset(${character}, ${axis}, ${axis_number});`);
    }

    //% block="获得角色[CHARACTER][AXIS]坐标" blockType="reporter"
    //% CHARACTER.shadow="string" CHARACTER.defl="Sprite"
    //% AXIS.shadow="dropdown" AXIS.options="AXIS"
    export function iWall_characterGetXY(parameter: any, block: any) {
        let character = parameter.CHARACTER.code;
        let axis = parameter.AXIS.code;
        Generator.addCode(`iWall.iWall_characterGetXY(${character}, ${axis})`);
    }

    //% block="获得角色[CHARACTER]图形方向" blockType="reporter"
    //% CHARACTER.shadow="string" CHARACTER.defl="Sprite"
    export function iWall_characterGetGraphDirect(parameter: any, block: any) {
        let character = parameter.CHARACTER.code;
        Generator.addCode(`iWall.iWall_characterGetGraphDirect(${character})`);
    }

    //% block="角色[GRAPHDIRECT]" blockType="reporter"
    //% GRAPHDIRECT.shadow="dropdown" GRAPHDIRECT.options="GRAPHDIRECT"
    export function iWall_GraphDirect(parameter: any, block: any) {
        let graphDirect = parameter.GRAPHDIRECT.code;
        Generator.addCode(`iWall.iWall_GraphDirect(${graphDirect})`);
    }

    //% block="获得角色[CHARACTER]运动方向" blockType="reporter"
    //% CHARACTER.shadow="string" CHARACTER.defl="Sprite"
    export function iWall_characterGetMotionDirect(parameter: any, block: any) {
        let character = parameter.CHARACTER.code;
        Generator.addCode(`iWall.iWall_characterGetMotionDirect(${character})`);
    }

    //% block="角色[MOTIONDIRECT]" blockType="reporter"
    //% MOTIONDIRECT.shadow="dropdown" MOTIONDIRECT.options="MOTIONDIRECT"
    export function iWall_MotionDirect(parameter: any, block: any) {
        let motionDirect = parameter.MOTIONDIRECT.code;
        Generator.addCode(`iWall.iWall_MotionDirect(${motionDirect})`);
    }

    //% block="角色[CHARACTER][VISIBILITY]" blockType="command"
    //% CHARACTER.shadow="string" CHARACTER.defl="Sprite"
    //% VISIBILITY.shadow="dropdown" VISIBILITY.options="VISIBILITY"
    export function iWall_characterSetVisible(parameter: any, block: any) {
        let character = parameter.CHARACTER.code;
        let visibility = parameter.VISIBILITY.code;
        Generator.addCode(`iWall.iWall_characterSetVisible(${character}, ${visibility});`);
    }

    //% block="角色[CHARACTER]移动图层到[LAYER_MODE]" blockType="command"
    //% CHARACTER.shadow="string" CHARACTER.defl="Sprite"
    //% LAYER_MODE.shadow="dropdown" LAYER_MODE.options="LAYER_MODE"
    export function iWall_characterSetLayer(parameter: any, block: any) {
        let character = parameter.CHARACTER.code;
        let layer_mode = parameter.LAYER_MODE.code;
        Generator.addCode(`iWall.iWall_characterSetLayer(${character}, ${layer_mode});`);
    }

    //% block="角色[CHARACTER]遇到边缘[EDGE_MODE]" blockType="command"
    //% CHARACTER.shadow="string" CHARACTER.defl="Sprite"
    //% EDGE_MODE.shadow="dropdown" EDGE_MODE.options="EDGE_MODE"
    export function iWall_characterSetEdgeMode(parameter: any, block: any) {
        let character = parameter.CHARACTER.code;
        let edge_mode = parameter.EDGE_MODE.code;
        Generator.addCode(`iWall.iWall_characterSetEdgeMode(${character}, ${edge_mode});`);
    }

    //% block="角色[CHARACTER][FLIP]翻转" blockType="command"
    //% CHARACTER.shadow="string" CHARACTER.defl="Sprite"
    //% FLIP.shadow="dropdown" FLIP.options="FLIP"
    export function iWall_characterFlip(parameter: any, block: any) {
        let character = parameter.CHARACTER.code;
        let flip = parameter.FLIP.code;
        Generator.addCode(`iWall.iWall_characterFlip(${character}, ${flip});`);
    }

    //% block="角色[CHARACTER]遇到边缘时[FLIP_MODE]" blockType="command"
    //% CHARACTER.shadow="string" CHARACTER.defl="Sprite"
    //% FLIP_MODE.shadow="dropdown" FLIP_MODE.options="FLIP_MODE"
    export function iWall_characterSetFlipMode(parameter: any, block: any) {
        let character = parameter.CHARACTER.code;
        let filp_mode = parameter.FLIP_MODE.code;
        Generator.addCode(`iWall.iWall_characterSetFlipMode(${character}, ${filp_mode});`);
    }

    //% block="角色[CHARACTER_A]与[CHARACTER_B]是否碰撞" blockType="boolean"
    //% CHARACTER_A.shadow="string" CHARACTER_A.defl="Sprite"
    //% CHARACTER_B.shadow="string" CHARACTER_B.defl="Sprite"
    export function iWall_characterGetCharsCollision(parameter: any, block: any) {
        let character_a = parameter.CHARACTER_A.code;
        let character_b = parameter.CHARACTER_B.code;
        Generator.addCode(`iWall.iWall_characterGetCharsCollision(${character_a}, ${character_b})`);
    }

    //% block="获取角色[CHARACTER_A]与[CHARACTER_B]的距离" blockType="reporter"
    //% CHARACTER_A.shadow="string" CHARACTER_A.defl="Sprite"
    //% CHARACTER_B.shadow="string" CHARACTER_B.defl="Sprite"
    export function iWall_characterGetCharsDistance(parameter: any, block: any) {
        let character_a = parameter.CHARACTER_A.code;
        let character_b = parameter.CHARACTER_B.code;
        Generator.addCode(`iWall.iWall_characterGetCharsDistance(${character_a}, ${character_b})`);
    }

    //% block="获取角色[CHARACTER]与[EDGE]边界的距离" blockType="reporter"
    //% CHARACTER.shadow="string" CHARACTER.defl="Sprite"
    //% EDGE.shadow="dropdown" EDGE.options="EDGE"
    export function iWall_characterGetCharToEdgeDistance(parameter: any, block: any) {
        let character = parameter.CHARACTER.code;
        let edge = parameter.EDGE.code;
        Generator.addCode(`iWall.iWall_characterGetCharToEdgeDistance(${character}, ${edge})`);
    }

    //% block="---"
    export function noteSep2() {

    }

    //% block="设置背景为[BACKGROUND_TYPE]" blockType="command"
    //% BACKGROUND_TYPE.shadow="dropdown" BACKGROUND_TYPE.options="BACKGROUND_TYPE"
    export function iWall_backSet(parameter: any, block: any) {
        let background_type = parameter.BACKGROUND_TYPE.code;
        Generator.addCode(`iWall.iWall_backSet(${background_type});`);
    }

    //% block="背景移动[STEP]向[MOTIONDIRECT]" blockType="command"
    //% STEP.shadow="number" STEP.defl="1"
    //% MOTIONDIRECT.shadow="dropdown" MOTIONDIRECT.options="MOTIONDIRECT"
    export function iWall_backMove(parameter: any, block: any) {
        let step = parameter.STEP.code;
        let motionDirect = parameter.MOTIONDIRECT.code;
        Generator.addCode(`iWall.iWall_backMove(${step}, ${motionDirect});`);
    }

    //% block="背景每[TIME]（毫秒）向[MOTIONDIRECT]移动一格" blockType="command"
    //% TIME.shadow="number" TIME.defl="300"
    //% MOTIONDIRECT.shadow="dropdown" MOTIONDIRECT.options="MOTIONDIRECT"
    export function iWall_backAutoMove(parameter: any, block: any) {
        let time = parameter.TIME.code;
        let motionDirect = parameter.MOTIONDIRECT.code;
        Generator.addCode(`iWall.iWall_backAutoMove(${time}, ${motionDirect});`);
    }

    //% block="---"
    export function noteSep3() {

    }

    //% block="传感器初始化[SENSOR]" blockType="command"
    //% SENSOR.shadow="dropdown" SENSOR.options="SENSOR"
    export function iWall_SensorInit(parameter: any, block: any) {
        let sensor = parameter.SENSOR.code;
        Generator.addSetup(`iWall_SensorInit`, `iWall.iWall_SensorInit(${sensor});`);
    }

    //% block="传感器数值获取[SENSOR_DATA]" blockType="reporter"
    //% SENSOR_DATA.shadow="dropdown" SENSOR_DATA.options="SENSOR_DATA"
    export function iWall_SensorGet(parameter: any, block: any) {
        let sensor_data = parameter.SENSOR_DATA.code;
        Generator.addCode(`iWall.iWall_SensorGet(${sensor_data})`);
    }

    //% block="---"
    export function noteSep4() {

    }

    //% block="清空画布" blockType="command"
    export function iWall_LEDMatrixClear(parameter: any, block: any) {
        Generator.addCode(`iWall.iWall_LEDMatrixClear();`);
    }

    //% block="红[RED]绿[GREEN]蓝[BLUE]" blockType="reporter"
    //% RED.shadow="range" RED.params.min=0 RED.params.max=255 RED.defl=0
    //% GREEN.shadow="range" GREEN.params.min=0 GREEN.params.max=255 GREEN.defl=0
    //% BLUE.shadow="range" BLUE.params.min=0 BLUE.params.max=255 BLUE.defl=0
    export function iWall_RGB(parameter: any, block: any) {
        let red = parameter.RED.code;
        let green = parameter.GREEN.code;
        let blue = parameter.BLUE.code;
        Generator.addCode(`iWall.iWall_RGB(${red}, ${green}, ${blue})`);
    }

    //% externalFunc
    export function getColorsFunc_() {
        return [
            "#ff0000", "#ff8000", "#ffff00", "#ff9da5",
            "#00ff00", "#b09eff", "#00ffff", "#007fff",
            "#65471f", "#0000ff", "#7f00ff", "#ff0080",
            "#ff00ff", "#ffffff", "#999999", "#000000"
        ]
    }

    //% block="画点 X[POSITION_X]Y[POSITION_Y]颜色[COLOR]" blockType="command"
    //% POSITION_X.shadow="range" POSITION_X.params.min=0 POSITION_X.params.max=33 POSITION_X.defl=0
    //% POSITION_Y.shadow="range" POSITION_Y.params.min=0 POSITION_Y.params.max=29 POSITION_Y.defl=0
    //% COLOR.shadow="colorPalette" COLOR.params.column=4
    //% COLOR.params.colorsFunc="getColorsFunc_"
    export function iWall_LEDMatrixSetPixel(parameter: any, block: any) {
        let position_x = parameter.POSITION_X.code;
        let position_y = parameter.POSITION_Y.code;
        let color = parameter.COLOR.code;
        Generator.addCode(`iWall.iWall_LEDMatrixSetPixel(${position_x}, ${position_y}, ${color});`);
    }

    //% block="画直线 起 X[START_X]Y[START_Y]止 X[END_X]Y[END_Y]颜色[COLOR]" blockType="command"
    //% START_X.shadow="range" START_X.params.min=0 START_X.params.max=33 START_X.defl=0
    //% START_Y.shadow="range" START_Y.params.min=0 START_Y.params.max=29 START_Y.defl=0
    //% END_X.shadow="range" END_X.params.min=0 END_X.params.max=33 END_X.defl=0
    //% END_Y.shadow="range" END_Y.params.min=0 END_Y.params.max=29 END_Y.defl=0
    //% COLOR.shadow="colorPalette" COLOR.params.column=4
    //% COLOR.params.colorsFunc="getColorsFunc_"
    export function iWall_LEDMatrixLine(parameter: any, block: any) {
        let start_x = parameter.START_X.code;
        let start_y = parameter.START_Y.code;
        let end_x = parameter.END_X.code;
        let end_y = parameter.END_Y.code;
        let color = parameter.COLOR.code;
        Generator.addCode(`iWall.iWall_LEDMatrixLine(${start_x}, ${start_y}, ${end_x}, ${end_y}, ${color});`);
    }

    //% block="画矩形 左上 X[TOP_LEFT_X]Y[TOP_LEFT_Y]右下 X[BOTTOM_RIGHT_X]Y[BOTTOM_RIGHT_Y]颜色[COLOR]模式[RECT_MODE]" blockType="command"
    //% TOP_LEFT_X.shadow="range" TOP_LEFT_X.params.min=0 TOP_LEFT_X.params.max=33 TOP_LEFT_X.defl=0
    //% TOP_LEFT_Y.shadow="range" TOP_LEFT_Y.params.min=0 TOP_LEFT_Y.params.max=29 TOP_LEFT_Y.defl=0
    //% BOTTOM_RIGHT_X.shadow="range" BOTTOM_RIGHT_X.params.min=0 BOTTOM_RIGHT_X.params.max=33 BOTTOM_RIGHT_X.defl=0
    //% BOTTOM_RIGHT_Y.shadow="range" BOTTOM_RIGHT_Y.params.min=0 BOTTOM_RIGHT_Y.params.max=29 BOTTOM_RIGHT_Y.defl=0
    //% COLOR.shadow="colorPalette" COLOR.params.column=4
    //% COLOR.params.colorsFunc="getColorsFunc_"
    //% RECT_MODE.shadow="dropdown" RECT_MODE.options="RECT_MODE"
    export function iWall_LEDMatrixRect(parameter: any, block: any) {
        let top_left_x = parameter.TOP_LEFT_X.code;
        let top_left_y = parameter.TOP_LEFT_Y.code;
        let bottom_right_x = parameter.BOTTOM_RIGHT_X.code;
        let bottom_right_y = parameter.BOTTOM_RIGHT_Y.code;
        let color = parameter.COLOR.code;
        let rect_mode = parameter.RECT_MODE.code;
        Generator.addCode(`iWall.iWall_LEDMatrixRect(${top_left_x}, ${top_left_y}, ${bottom_right_x}, ${bottom_right_y}, ${color}, ${rect_mode});`);
    }

    //% block="画面移动 方向[CANVAS_DIRECT]格数[STEP]" blockType="command"
    //% CANVAS_DIRECT.shadow="dropdown" CANVAS_DIRECT.options="CANVAS_DIRECT"
    //% STEP.shadow="number" STEP.defl="0"
    export function iWall_LEDMatrixShift(parameter: any, block: any) {
        let canvas_direct = parameter.CANVAS_DIRECT.code;
        let step = parameter.STEP.code;
        Generator.addCode(`iWall.iWall_LEDMatrixShift(${canvas_direct}, ${step});`);
    }

    //% block="---"
    export function noteSep5() {

    }

    //% block="创建文本框 X[POSITION_X]Y[POSITION_Y]字体[TEXT_FONT]宽[WIDTH]" blockType="reporter"
    //% POSITION_X.shadow="range" POSITION_X.params.min=0 POSITION_X.params.max=33 POSITION_X.defl=0
    //% POSITION_Y.shadow="range" POSITION_Y.params.min=0 POSITION_Y.params.max=29 POSITION_Y.defl=0
    //% TEXT_FONT.shadow="dropdown" TEXT_FONT.options="TEXT_FONT"
    //% WIDTH.shadow="number" WIDTH.defl="10"
    export function iWall_createTextFrame(parameter: any, block: any) {
        let position_x = parameter.POSITION_X.code;
        let position_y = parameter.POSITION_Y.code;
        let text_font = parameter.TEXT_FONT.code;
        let width = parameter.WIDTH.code;
        Generator.addCode(`iWall.iWall_createTextFrame(${position_x}, ${position_y}, ${text_font}, ${width})`);
    }

    //% block="文本框[TEXTAREA]移动到 X[POSITION_X]Y[POSITION_Y]" blockType="command"
    //% TEXTAREA.shadow="string" TEXTAREA.defl="Textarea"
    //% POSITION_X.shadow="range" POSITION_X.params.min=0 POSITION_X.params.max=33 POSITION_X.defl=0
    //% POSITION_Y.shadow="range" POSITION_Y.params.min=0 POSITION_Y.params.max=29 POSITION_Y.defl=0
    export function iWall_textSetXY(parameter: any, block: any) {
        let textarea = parameter.TEXTAREA.code;
        let position_x = parameter.POSITION_X.code;
        let position_y = parameter.POSITION_Y.code;
        Generator.addCode(`iWall.iWall_textSetXY(${textarea}, ${position_x}, ${position_y});`);
    }

    //% block="文本框[TEXTAREA]设置文字[TEXT]颜色[COLOR]" blockType="command"
    //% TEXTAREA.shadow="string" TEXTAREA.defl="Textarea"
    //% TEXT.shadow="string" TEXT.defl=""
    //% COLOR.shadow="colorPalette" COLOR.params.column=4
    //% COLOR.params.colorsFunc="getColorsFunc_"
    export function iWall_textSetText(parameter: any, block: any) {
        let textarea = parameter.TEXTAREA.code;
        let text = parameter.TEXT.code;
        let color = parameter.COLOR.code;
        Generator.addCode(`iWall.iWall_textSetText(${textarea}, ${text}, ${color});`);
    }

    //% block="---"
    export function noteSep6() {

    }

    //% block="播放背景音乐[BACK_MUSIC_TYPE]" blockType="command"
    //% BACK_MUSIC_TYPE.shadow="dropdown" BACK_MUSIC_TYPE.options="BACK_MUSIC_TYPE"
    export function iWall_musicBackPlay(parameter: any, block: any) {
        let back_music_type = parameter.BACK_MUSIC_TYPE.code;
        Generator.addCode(`iWall.iWall_musicBackPlay(${back_music_type});`);
    }

    //% block="背景音乐暂停" blockType="command"
    export function iWall_musicBackPause(parameter: any, block: any) {
        Generator.addCode(`iWall.iWall_musicBackPause();`);
    }

    //% block="背景音乐停止" blockType="command"
    export function iWall_musicBackStop(parameter: any, block: any) {
        Generator.addCode(`iWall.iWall_musicBackStop();`);
    }

    //% block="背景音乐继续" blockType="command"
    export function iWall_musicBackResume(parameter: any, block: any) {
        Generator.addCode(`iWall.iWall_musicBackResume();`);
    }

    //% block="播放声音[MUSIC_TYPE]" blockType="command"
    //% MUSIC_TYPE.shadow="dropdown" MUSIC_TYPE.options="MUSIC_TYPE"
    export function iWall_musicSoundPlay(parameter: any, block: any) {
        let music_type = parameter.MUSIC_TYPE.code;
        Generator.addCode(`iWall.iWall_musicSoundPlay(${music_type});`);
    }
}